package com.lovo.active.frame;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;

import javax.swing.BorderFactory;
import javax.swing.JFrame;
import javax.swing.JPanel;

import com.lovo.common.model.SchoolBean;
import com.lovo.netCRM.component.LovoButton;
import com.lovo.netCRM.component.LovoCutPage;
import com.lovo.netCRM.component.LovoList;
import com.lovo.netCRM.component.LovoTable;
import com.lovo.netCRM.component.LovoTitleLabel;

/**
 * 学校活动主界面
 * @author 白德柯
 *
 */
public class ActivePanel extends JPanel{

	/**学校活动表格组件*/
	private LovoTable activeTable;
	/**窗体组件*/
	private JFrame jf;
	/**学校列表*/
	private LovoList<SchoolBean> schoolList;

	/**分页对象*/
	private LovoCutPage cutPage;

	public ActivePanel(JFrame jf){
		this.jf = jf;
		this.setLayout(null);
		this.init();
	}
	/**
	 * 初始化
	 *
	 */
	private void init() {
		new LovoTitleLabel("学 校 活 动",this);
		this.initTable();
		this.initList();
		this.initButton();
		this.initData();
	}
	/**
	 * 初始化数据
	 */
	public void initData(){
		this.updateTable(1);
	}
	
	

	
	//-------------------------------------------------
	/**
	 * 初始化表格
	 *
	 */
	private void initTable() {
		activeTable = new LovoTable(this,
				new String[]{"活动名称","时间","地点","主题","负责部门","负责人"},
				new String[]{},//学校活动实体属性名数组 
				"");//主键属性名 
		activeTable.setSizeAndLocation(220, 90, 500, 300);
		// 分页
		cutPage = new LovoCutPage(220,400,this) {
			@Override
			public void clickEvent(int arg0) {
			}
		};
	}
	
	/**
	 * 初始化按钮
	 *
	 */
	private void initButton() {
		LovoButton addButton = new LovoButton(250,460,"添加活动","image/update.png",this);
		
		addButton.addActionListener(new ActionListener() {
			
			@Override
			public void actionPerformed(ActionEvent e) {
				new ActiveAddDialog(jf,0, ActivePanel.this);
			}
		});
		

	}
	/**
	 * 初始化列表
	 */
	private void initList() {
		schoolList = new LovoList(20, 90, 195, 300, new ArrayList(), this);
		schoolList.setBorder(BorderFactory.createEtchedBorder());
	}
	/**
	 * 更新表格数据
	 */
	private void updateTable(int page){
		//更新表格
		activeTable.updateLovoTable(null);
	}

}
